package cn.itscloudy.simpleorgintro.util

import cn.itscloudy.simpleorgintro.SimpleOrgIntroApplication
import org.apache.commons.io.IOUtils
import java.io.IOException
import java.nio.charset.StandardCharsets

object ApplicationUtil {

    fun getResourceContent(path: String): String {
        try {
            SimpleOrgIntroApplication::class.java.getResourceAsStream(path).use { `is` ->
                assert(`is` != null)
                return IOUtils.toString(`is`, StandardCharsets.UTF_8)
            }
        } catch (e: IOException) {
            throw RuntimeException("无法获取资源" + path + "内容", e)
        }
    }
}